// pages/main/others/tourist.js
import {alltourist} from "../../../api/wrd/index"
import {searchtourist} from "../../../api/wrd/index"
Page({
  data: {
    touristlist:[],
    serchdata:{}
  },
  async alltourist(){
    let res=await alltourist()
    this.setData({
      touristlist:res.dataset
    })
    console.log("游客列表",this.data.touristlist);
  },
  gotouristdetail(event){
    wx.setStorageSync('offeredid', event.currentTarget.dataset.offeredid)
    wx.setStorageSync('orderid', event.currentTarget.dataset.orderid)
    wx.navigateTo({
      url: "../others/touristdetail",
    })
  },
  gotouristsearch(){
    wx.navigateTo({
      url: "../others/touristsearch",
    })
  },
  //搜索游客
  async getsearch(){
    this.setData({
      serchdata:JSON.parse(wx.getStorageSync('searchinfo'))
    })
    let res=await searchtourist(this.data.serchdata)
    this.setData({
      touristlist:res.dataset
    })
    console.log("搜索到的旅游信息",res);
  },
  onLoad(options) {
    if(wx.getStorageSync('searchinfo')){
        console.log(wx.getStorageSync('searchinfo'));
        console.log("search",JSON.parse(wx.getStorageSync('searchinfo')));
        this.getsearch()
        wx.removeStorageSync('searchinfo')
    }else{
        this.alltourist()
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },
  onUnload() {
   
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})